package com.tencent.wxcloudrun.utils;

public class TaskUtil {

    // 计算任务金额
    public static Double calculateMonthlyRepayment(Double loanAmount, Integer termMonths, Double interestRate) {
        // 等额本息计算公式: 每月还款金额 = 本金 * (月利率 * (1 + 月利率)^期数) / ((1 + 月利率)^期数 - 1)
        Double monthlyRate = interestRate;
        Double numerator = loanAmount * monthlyRate * Math.pow(1 + monthlyRate, termMonths);
        Double denominator = Math.pow(1 + monthlyRate, termMonths) - 1;
        return numerator / denominator;
    }
}
